#!/bin/bash

dir=$(dirname $0)
oldFile="${dir}/old.txt"
currentFile="${dir}/current.txt"
newFile="${dir}/new.txt"
diffFile="${dir}/diff.txt"

# Back up current file
cp $currentFile $oldFile
# Create a diff of old and new
diff <(cat $currentFile |sort | uniq) <( cat $newFile | sort | uniq) | awk '/>/ { print $2 }' > $diffFile
# Add the new stuff to the current file
cat $diffFile >> $currentFile
# Show the diff
cat $diffFile
# Empty the new file
cat /dev/null > $newFile

